﻿using FineAdmin.IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace HuiJi.CMS.Blog.Controllers
{
    public class GoodController : BaseController
    {
        // GET: good
        public IMaterialGoodsService MaterialGoodsService { get; set; }
        public ActionResult Index(int? pn, int? px,int p = 1, int sort = 4, string key = "")
        {
            ViewBag.Active = "Good";
            ViewBag.Page = p;
            ViewBag.Key = key;
            ViewBag.Price_Min = pn;
            ViewBag.Price_Max = px;
            ViewBag.Sort = sort;

            ViewBag.ShowSite = SystemParameterService.GetByCode("ShowSite").SPValue;

            //今日更新数
            ViewBag.ToDayCount = MaterialGoodsService.CountByWhere("where CreateTime >= '" + DateTime.Now.Date.ToString("yyyy-MM-dd HH:mm:ss") + "'");
            int total;
            ViewBag.GoodsList = MaterialGoodsService.GetDistinctListByFilter(new FineAdmin.Model.MaterialGoodsModel()
            {
                Title = key,
                S_Price = pn,
                B_Price = px,
                OrderType = (FineAdmin.Common.OrdrRuleEnum)sort
            }, new FineAdmin.Model.PageInfo()
            {
                page = p,
                limit = 16,

            }, out total); ;

            ViewBag.Total = total;

            return View();
        }
    }
}